import request from "@/utils/request";
import { MenuQuery, MenuVO,MenusForm } from "./types";
import {AxiosPromise} from "axios";

/**
 * 获取路由列表
 */
export function listRoutes() {
  return request({
    url: "/admin/permission/getAll",
    method: "get",
    params: {
      type: "element-plus"
    }
  });
}

export function getAll() {
  return request({
    url: '/admin/permission/getSelectData',
    method: 'get'
  })
}

export function getData(queryParams?: MenuQuery)  {
  return request({
    url: '/admin/permission/getData',
    method: 'get',
    params: queryParams
  })
}

export function permissionDisable(data: any) {
  return request({
    url: '/admin/permission/disable',
    method: 'post',
    data
  })
}

export function permissionEnable(data: any) {
  return request({
    url: '/admin/permission/enable',
    method: 'post',
    data
  })
}

export function createPermission(data: any) {
  return request({
    url: '/admin/permission/add',
    method: 'post',
    data
  })
}

export function updatePermission(data: any) {
  return request({
    url: '/admin/permission/edit',
    method: 'put',
    data
  })
}

export function delPermission(data: any) {
  return request({
    url: '/admin/permission/del',
    method: 'delete',
    data
  })
}

export function getMenuForm(ids: number): AxiosPromise<MenusForm> {
  return request({
    url: "/admin/permission/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}
